package com.hh.service.imp;

import com.hh.dao.PersonDao;
import com.hh.entity.Person;
import com.hh.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service
/*propagation事务的传播方式 isolation事务的隔离级别事务属性有五个方面：传播行为，隔离级别，事务超时时间，回滚规则，是否只读。
* https://blog.csdn.net/soonfly/article/details/70305585 详细地址*/
@Transactional(propagation= Propagation.REQUIRED,isolation= Isolation.DEFAULT,timeout=5)
public class PersonServiceImp implements PersonService {
    @Autowired
    private PersonDao personDao;
    @Override

    public void updata(Person person) {
        personDao.updata(person);
    }

    @Override
    public Person byId(Integer id) {
        return personDao.getByid(id);
    }

    @Override
    public List<Person> findAll() {
        return personDao.findAll(Person.class);
    }


}
